<?php
// +----------------------------------------------------------------------
//            -------------------------
//           /   / ----------------\  \
//          /   /             \  \
//         /   /              /  /
//        /   /    /-------------- /  /
//       /   /    /-------------------\  \
//      /   /                   \  \
//     /   /                     \  \
//    /   /                      /  /
//   /   /      /----------------------- /  /
//  /-----/      /---------------------------/
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://baimifan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Sage 2016/4/19  14:05
// +----------------------------------------------------------------------
 

namespace Common\Model;
use Think\Model;

/*
 * Parameter参数表
 * */
class AddressModel extends Model
{
    protected $tableName = 'Address';
    //获取借书运费
    function getFreightRent($province,$city,$district){
        $dis=M("District");
        $map["name"]=$province;
        $map["level"]=1;
        $dp=$dis->where($map)->field("id")->find();

        $map["name"]=$city;
        $map["level"]=2;
        $map["pid"]=$dp['id'];
        $dc=$dis->where($map)->field("id")->find();

        $map["name"]=$district;
        $map["level"]=3;
        $map["pid"]=$dc['id'];
        $dd=$dis->where($map)->field("price_rent")->find();
        if($dd){
            return $dd["price_rent"];
        }else{
            return false;
        }
    }

    //获取购书运费
    function getFreightBuy($province,$city,$district){
        $dis=M("District");
        $map["name"]=$province;
        $map["level"]=1;
        $dp=$dis->where($map)->field("id")->find();

        $map["name"]=$city;
        $map["level"]=2;
        $map["pid"]=$dp['id'];
        $dc=$dis->where($map)->field("id")->find();

        $map["name"]=$district;
        $map["level"]=3;
        $map["pid"]=$dc['id'];
        $dd=$dis->where($map)->field("price_buy")->find();
        if($dd){
            return $dd["price_buy"];
        }else{
            return false;
        }
    }
}